import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
// import NProgress from 'nprogress'; // progress bar
import { parseProjectId } from '../utils/localstorage';
// NProgress.configure({ showSpinner: false }); // NProgress Configuration
const routes: Array<RouteRecordRaw> = [
	{
		path: '/',
		redirect: '/login'
	},
	{
		path: '/login',
		name: 'login',
		component: () => import('@/views/Login/index.vue')
	},
	{
		path: '/local',
		name: 'local',
		component: () => import('@/views/Enter/Local.vue')
	},
	{
		path: '/edit',
		name: 'edit',
		component: () => import('@/views/Enter/Edit.vue')
	},
	{
		path: '/preview',
		name: 'preview',
		component: () => import('@/views/Enter/Preview.vue')
	},
	{
		path: '/production',
		name: 'production',
		component: () => import('@/views/Enter/Production.vue')
	}
];

const router = createRouter({
	history:
		import.meta.env.MODE !== 'production'
			? createWebHistory(`/graphics-engine/${import.meta.env.VITE_API_DEFAULT_PRJ}`)
			: createWebHistory(`/graphics-engine/${parseProjectId()}`),
	routes
});

export default router;
